package bjtuoj;

import java.util.Map;
import java.util.Scanner;

/**
 * ClassName: Homework_4_B
 * Description:
 * date: 2021-11-30 21:16
 *
 * @author liyifan
 */
public class Homework_4_B {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] arr = new int[N + 1];
        int sum = 0;
        for (int i = 0; i < N; i++) {
            arr[i] = scanner.nextInt();
            sum += arr[i];
        }
        int ans = 0;
        sum = sum / N;
        for (int i = 0; i < N; i++) {
            if (arr[i] != sum) {
                arr[i + 1] -= sum - arr[i];
                ans++;
            }
        }
        System.out.printf("%d\n", ans);

    }

}
